require 'rubygems'
require 'spork'

ENV["RAILS_ENV"] ||= 'test'

Spork.prefork do
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'capybara/rspec'
  require 'webmock/rspec'
end

Spork.each_run {}

Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
Dir[Rails.root.join("spec/shared_examples/**/*.rb")].each {|f| require f}

RSpec.configure do |config|
  config.mock_with :rspec

  config.use_transactional_fixtures = true

  config.before do
    if example.metadata[:js]
      Capybara.current_driver = :akephalos
      WebMock.allow_net_connect!
    end
  end

  config.after do
    Capybara.use_default_driver if example.metadata[:js]
    WebMock.disable_net_connect!
  end

  config.filter_run :focus => true
  config.run_all_when_everything_filtered = true

  config.include Factory::Syntax::Methods
  # include Macros::Webmock
  # include Macros::Redis

  # config.include Macros::MobileMenu,
  #   :example_group => {:file_path => config.escaped_path(%w[spec])}
  # config.include Macros::Admin,
  #   :example_group => {:file_path => config.escaped_path(%w[requests])}

end